package com.noble.glamour.ui.agora.act.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.noble.library.base.bean.BaseData;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * faceU道具
 * <p>
 * Created by Su on 2017/7/20.
 */
public class RtcProps extends BaseData implements Parcelable{
    private List<Props> propsList = new ArrayList<>();

    @Override
    public void parseJson(String jsonStr) {
        String jsonData = getJsonObject(jsonStr).optString("res");
        JSONObject jsonObject = getJsonObject(jsonData);
        if (!jsonObject.isNull("props")) {
            this.propsList = (List<Props>) getBaseDataList(jsonObject.optJSONArray("props"), Props.class);
        }
    }

    public List<Props> getPropsList() {
        return propsList;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(this.propsList);
    }

    public RtcProps() {
    }

    protected RtcProps(Parcel in) {
        this.propsList = in.createTypedArrayList(Props.CREATOR);
    }

    public static final Creator<RtcProps> CREATOR = new Creator<RtcProps>() {
        @Override
        public RtcProps createFromParcel(Parcel source) {
            return new RtcProps(source);
        }

        @Override
        public RtcProps[] newArray(int size) {
            return new RtcProps[size];
        }
    };

    @Override
    public String toString() {
        return "RtcProps{" +
                "propsList=" + propsList +
                '}';
    }
}
